<?php
/**
 * Created by PhpStorm.
 * User: adminchyistrator
 * Date: 2018/12/8
 * Time: 10:45
 */

namespace app\adminchy\controller;

use think\facade\Request;
use think\facade\Session;
use think\Controller;
use app\adminchy\controller\Base;
use think\Db;

class Index extends Base
{
    //后台首页
    public function index(){
        $Uid=Session::get('user.id');
        $username = Db::name('snake_user')->where(['id'=>$Uid])->value('user_name');
        $this->assign('user_name',$username);
        return view('Index/index');
    }
    //默认首页
    public function indexMain(){
        $Uid=Session::get('user.id');
        $username = Db::name('snake_user')->where(['id'=>$Uid])->value('user_name');
        echo '欢迎您'.$username.',进入樱桃社区后台管理系统!';
    }
    //系统参数
    public function configShow(){
        $data = Db::name('config')->find();
        $this->assign('config',$data);
        return view('Index/config');
    }
    //系统参数修改
    public function configEdit(){
        $data = Request::post();
        $info = Db::name('config')->where('id',1)->update($data);
        if ($info){
            return json(['status'=>0,'message'=>'修改成功']);
        }else{
            return json(['status'=>1,'message'=>'修改失败']);
        }
    }
}